package com.skywalker.j2cache;

import com.jfinal.kit.StrKit;
import com.skywalker.common.model.Account;

import java.util.Date;

/**
 * user: skywalker
 * date: 2019/4/13 22:01
 */
public class J2CacheService {

    public Account getAccountInfo(String name) {
        if (StrKit.isBlank(name)) {
            return null;
        }
        return Account.dao.findByName(name);
    }

    public Account saveAccount(String nickName) {
        if (StrKit.notBlank(nickName)) {
            Account account = new Account();
            account.setNickName(nickName);
            account.setUserName(nickName);
            account.setPassword(nickName);
            account.setSalt(nickName);
            account.setLikeCount(1);
            account.setAvatar(nickName);
            account.setCreateAt(new Date());
            account.setStatus(1);
            account.save();
            return account;
        } else {
            return null;
        }

    }
}
